<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>js中的对象</title>
		<script>
			class Animal{
				//构造方法
				constructor(a,b){
					this.type=a;
					this.name=b;
				}
				say(){
					alert("我是一只"+this.type+"名字叫"+this.name+"的狗");
				}
			}
			class Dog extends Animal{
				//默认值
				constructor(a="无名",b="小狗",age=1) {
				    super(a,b);
					this.age=age;
				}
				say(){
					super.say();
					alert("年龄是"+this.age+"岁");
				}
				bite(b){
					alert(this.name+"咬了"+b);
				}
			}
			/* var d=new Animal("哈士奇","柴家王");
			d.say();
			var d2=new Dog("德国牧羊犬","大花",4);
			d2.say();
			d2.bite("桂群"); */
			//var d3=new Dog("德国牧羊犬","大花",4);
			var d3=new Dog();
			d3.say();
		</script>
	</head>
	<body>
	</body>
</html>
